import requests


class IHRMDepManageApi:

    # 封装部门添加的方法
    @classmethod
    def add_dep_api(cls, token, add_department_body):
        url = "http://ihrm2-test.itheima.net/api/company/department"
        header = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.post(url=url, headers=header,
                             json=add_department_body)
        return resp

    # 封装部门查询的方法
    @classmethod
    def query_dep_api(cls, dep_id, token):
        url = "http://ihrm2-test.itheima.net/api/company/department/" + dep_id
        header = {"Authorization": token}
        resp = requests.get(url=url, headers=header)
        return resp

    # 封装部门修改的方法
    @classmethod
    def modify_dep_api(cls, dep_id, token, modify_deparment_body):
        url = "http://ihrm2-test.itheima.net/api/company/department/" + dep_id
        header = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.put(url=url, headers=header,
                            json=modify_deparment_body)
        return resp

    # 封装部门删除的方法
    @classmethod
    def del_dep_api(cls, dep_id, token):
        url = "http://ihrm2-test.itheima.net/api/company/department/" + dep_id
        header = {"Authorization": token}
        resp = requests.delete(url=url, headers=header)
        return resp

    pass
